<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
          <button @click="msg='你坏'">修改msg</button>
          <p>{{ msg }}</p>

          <h3>以下侦听obj</h3>
          <button @click="obj.name = 'rose'">修改obj.name</button>
          <button @click="obj = { name: 'rose', age: 16 }">修改obj指向</button>
          <p>{{ obj }}</p>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data () {
          return {
            msg: '你好',
            obj: {
                name: 'jack',
                age: 16
            }
          }
        },
        watch: {
            msg () {
                console.log('msg变换了')
            },
            // 侦听obj，相当于就是看obj这个变量保存的值有没有变化
            // 而obj其实没变化
            obj () {
                console.log('obj被改变了')
            }
        }
      })
    </script>
  </body>
</html>